Runs the process with additional arguments and returns the exit code.
Syntax
Parameters
- input
- arguments
Example
Library/Library.Test/TestProcessRunner.cs
C# | Copy Code |
---|
using (ProcessRunner runner = new ProcessRunner("cmd.exe", "/C", "sort"))
{
List<string> lines = new List<string>();
runner.OutputReceived += delegate(Object o, ProcessOutputEventArgs e) { lines.Add(e.Data); };
int exitCode = runner.Run(new StringReader("Hello World\r\nWhatever!\r\nA line that goes first."));
Assert.AreEqual(0, exitCode);
Assert.AreEqual("A line that goes first.", lines[0]);
Assert.AreEqual("Hello World", lines[1]);
Assert.AreEqual("Whatever!", lines[2]);
} |
VB.NET | Copy Code |
---|
Using runner As New ProcessRunner("cmd.exe", "/C", "sort")
Dim lines As New List(Of String)()
runner.OutputReceived += Function(o As [Object], e As ProcessOutputEventArgs) Do
lines.Add(e.Data)
End Function
Dim exitCode As Integer = runner.Run(New StringReader("Hello World" & vbCr & vbLf & "Whatever!" & vbCr & vbLf & "A line that goes first."))
Assert.AreEqual(0, exitCode)
Assert.AreEqual("A line that goes first.", lines(0))
Assert.AreEqual("Hello World", lines(1))
Assert.AreEqual("Whatever!", lines(2))
End Using |
Requirements
Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7
See Also